/*
 * @Author: szx
 * @Date: 2022-02-25 14:39:38
 * @LastEditTime: 2022-02-25 14:42:04
 * @Description:
 * @FilePath: \leetcode\400-499\454\454_2.js
 */
/**
 * @param {number[]} nums1
 * @param {number[]} nums2
 * @param {number[]} nums3
 * @param {number[]} nums4
 * @return {number}
 */
var fourSumCount = function (nums1, nums2, nums3, nums4) {
    const map = new Map();
    for (let i = 0; i < nums1.length; i++) {
        for (let j = 0; j < nums2.length; j++) {
            const num = nums1[i] + nums2[j];
            map.set(num, (map.get(num) || 0) + 1);
        }
    }
    let res = 0;
    for (let i = 0; i < nums3.length; i++) {
        for (let j = 0; j < nums4.length; j++) {
            const num = -nums3[i] - nums4[j];
            if (map.has(num)) res += map.get(num);
        }
    }
    return res;
};
